home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gwedit.com / GWEDIT.DOC < prev    next >
Encoding:
Text File  |  1989-03-16  |  9.4 KB  |  251 lines

  1.                       GWEDIT  Version 2.01 
  2.                          by Michael Day
  3.                   Released to the public domain
  4.                        as of 16 March 1989
  5.  
  6.      GWEDIT  provides a graphics based string input for use  with 
  7. the Turbo Pascal BGI. The function GwRead accepts a string to  be 
  8. displayed on the screen and optionally edited.
  9.  
  10.      The  GwRead function will optionally allow the string to  be 
  11. edited.  When Edit is enabled, a cursor is simulated to  indicate 
  12. that  editing can occur. In Insert mode a block cursor is  shown. 
  13. In  overwrite mode a small block cursor is displayed. All of  the 
  14. normal  Wordstar  like  editing  commands  are  available   while 
  15. editing.  If  a non-editing/non-printable character  is  entered, 
  16. then the GwRead function is terminated returning the character as 
  17. the  function result. This allows the calling program  to  analys 
  18. the  function result and determine whether to re-enter GwRead  to 
  19. continue editing, or to act upon the command.
  20.  
  21.      GwRead  is  particularly useful  for  database  applications 
  22. since  it is ideally suited to field editing  applications  where 
  23. you want to use a loop to process the data but need to optionally 
  24. inhibit specific fields. Simply setting the Edit option to  false 
  25. will  disallow the string from being edited, but still allows  it 
  26. to be displayed on the screen within the function.
  27.  
  28.  
  29. function GwRead(X,Y,Wide,CPos:integer;
  30.                 Edit:boolean;
  31.                 Color:ColorRec;
  32.                 var S:string):char;
  33.  
  34.  
  35. X,Y : Sets the X,Y pixel location on the screen where the string 
  36.       will be drawn.
  37.  
  38. Wide : Sets the maximum string length allowed for editing.
  39.  
  40. CPos : Sets the starting location for the cursor when editing is 
  41.        enabled.
  42.  
  43. S : This is the string that gets displayed and can be edited.
  44.  
  45. Color : Color specifies the colors to be used when drawing the 
  46.         the string on the screen. It also specifies how the 
  47.         string is to be displayed.
  48.  
  49.         Color is futher broken down into:
  50.  
  51.         WritePos : Specifies how the string is to be displayed
  52.                    Options are LeftWrite, RightWrite, 
  53.                    CenterWrite, OffLeftWrite, and
  54.                    PoffLeftWrite 
  55.  
  56.         FColor : this sets the foreground color of the string
  57.         BColor : this sets the background color of the string
  58.         BPattern : this sets the background pattern used with 
  59.                    the string  
  60.  
  61.  
  62. In addition to the parameters passed in the function call,  there 
  63. are  four typed constants in GwEdit that control how  the  string 
  64. editing occurs. 
  65.  
  66.   ForceUpper : boolean = false;    
  67.  
  68. When  ForceUpper is true, all lower case characters inputed  will 
  69. be converted to upper case characters. When false, no  conversion 
  70. takes place.
  71.  
  72.  
  73.   InsertDefault : boolean = true;  
  74.  
  75. When  InsertDefault is true, the Edit mode will start  in  insert 
  76. mode.  Insert  mode  can  be toggled with  the  'Ins'  key  while 
  77. editing.  When  InsertDefault  is false, editing  will  start  in 
  78. Overwrite mode.
  79.  
  80.  
  81.   ClearFirstChar : boolean = true;  
  82.  
  83. When  ClearFirstChar is true, the string that was passed will  be 
  84. cleared  from  the  string if the first character  entered  is  a 
  85. displayable  character. Setting this flag to false  will  prevent 
  86. the string from being erased. A control R while in edit mode will 
  87. always restore the original string to the display.
  88.  
  89.  
  90.   EscapeRestore : boolean = false;  
  91.  
  92. When  EscapeRestore is true, the original string that was  passed 
  93. to the function will be restored when the ESC key is used to exit 
  94. the  function. When false the string as it currently  appears  on 
  95. the screen will be returned.
  96.  
  97.  
  98.  
  99. Editing:
  100.  
  101.      In  all cases, the following keys are allowed while  waiting 
  102. for key input in the string (this is regardless of the  condition 
  103. of the Edit flag:
  104.  
  105.         RetKey :                {Accept current string and quit}
  106.         EscKey :                {Restore default string and quit}
  107.         HomeKey :               {Cursor to begin of line}
  108.         EndKey :                {Cursor to end of line}
  109.         GwRestore :             {Restore default and continue}
  110.         GwLeft,LeftArrow :      {Cursor left by one character}
  111.         GwRight,RightArrow :    {Cursor right by one character}
  112.         GwWordLeft,CtrlLeft :   {Cursor left one word}
  113.         GwWordRight,CtrlRight : {Cursor right one word}
  114.         BackSpace,GwRub :       {Backspace one character}
  115.                                 {(character delete is inhibited)}   
  116.  
  117.      When  the Edit flag is true, the following  additional  Edit 
  118. controls are allowed:
  119.  
  120.         #32..#126:           {A character to enter in the string}
  121.         CtrlEnd :            {Delete from cursor to end of line}
  122.         CtrlHome :           {Delete from beg of line to cursor}
  123.         GwDelLine :          {Delete entire line}
  124.         GwDelChar,DelKey :   {Delete current character}
  125.         GwDelWord :          {Delete word to right of cursor}
  126.         InsKey :             {Toggle insert mode}
  127.         BackSpace,GwRub :    {Backspace one character}
  128.                              {(deletes char under cursor)}
  129.  
  130.  
  131. The files in this package:
  132.  
  133. GSTART.PAS
  134.  
  135. GWSTART is my graphics startup unit. You can adapt it to your own 
  136. situation if it doesn't suit you. GSTART tries to reduce the various 
  137. display types to three common modes; CGA, EGA, or Hercules. The 
  138. reduces the amount of hassling that has to occur between displays.
  139.  
  140.  
  141. KEYCODES.PAS
  142.  
  143. KEYCODES is my standard keyboard code definition file. I use this 
  144. unit to keep all my keyboard codes in so that they are all located 
  145. in one place. This reduces conflicts between various programs and
  146. units since they all reference the KEYCODES unit.
  147.  
  148.  
  149. GCURSE.PAS
  150.  
  151. GCURSE  is  the cursor simulation unit. It simulates  a  flashing 
  152. text cursor while in graphics mode. The cursor can be  inhibited, 
  153. set to a full block cursor, or set to a small cursor. 
  154.  
  155.  
  156. AREAWR.PAS
  157.  
  158. AREAWR  performs the actual screen writeing of text  for  GWEDIT. 
  159. The  routines allow you to specify an X,Y location on the  screen 
  160. to place the text, then writes the string. 
  161.  
  162.  
  163. GWEDIT.PAS
  164.  
  165. GWEDIT  contains  the graphics line editor as described  in  this 
  166. documentation. 
  167.  
  168.  
  169. In  addition  to the files mention above that are  supplied  with 
  170. this  unit you will also need the GRAPH.TPU and the BGI file  for 
  171. your display type.  A CRT unit is also needed for the  KeyPressed 
  172. and  ReadKey functions. You can either use the CRT unit  provided 
  173. with TP, or you can use any of the alternate CRT units available.
  174.  
  175.  
  176.  
  177. The program TESTED.PAS has been provided as a quick example for
  178. using GWEDIT. It displays a string and then allows you to edit 
  179. it. To exit the program press the Escape key.
  180.  
  181.  
  182.  
  183. Using GwEdit's TFDD interface:
  184.  
  185. GWEDIT includes a TFDD (Text File Device Driver) as a part of the 
  186. unit.  To  use  the GwEdit TFDD, just Assign  it,  then  use  the 
  187. standard Readln and Write procedures to perform your I/O.
  188.  
  189. GwEdit's assignment procedure is:
  190.  
  191.      AssignGwCRT(var F:Text;
  192.                  X,Y,Wide,CPos:integer;
  193.                  Edit:boolean;
  194.                  Color:ColorRec;
  195.                  var S:string);
  196.  
  197.  
  198. Parameters  "X" and "Y" are the location on the screen where  you 
  199. want the string to appear (upper left corner). "Wide" is how wide 
  200. the  string  area will be in character positions. "CPos"  is  the 
  201. position  that the cursor is to be placed initially. When  "Edit" 
  202. is  true, then editing of the string is allowed. When  "Edit"  is 
  203. false, editing is not allow. "Color" contains the color defintion 
  204. for  the string as described for GWEDIT above. "S" is  a  working 
  205. string that is used to perform the screen writing and editing.
  206.  
  207.  
  208. An example of using the TFDD with GwEdit is shown below:
  209.  
  210.      AssignGwCRT(Gw,10,10,40,1,DummyColor,TS);
  211.      Reset(Gw);
  212.      TS := 'Edit this string';
  213.      Readln(Gw,Rs);
  214.  
  215.      Ws := 'You entered: '+Rs;
  216.      Rewrite(Gw);
  217.      Write(Gw,Ws);
  218.  
  219.  
  220. The  assignment sets the string to location 10,10 on the  screen, 
  221. sets  a  field width of 40 characters, places the cursor  at  the 
  222. first  character  in  the string, and uses  the  DummyColors  for 
  223. drawing. The Work string used is TS. Once Reset, The Work  string 
  224. is initialized to 'Edit this string' which will be displayed when 
  225. the  Readln function is called. The Readln function will  display 
  226. the  string  and  wait for a valid  completion  character  to  be 
  227. recieved.  A  valid complettion character  is  any  non-printable 
  228. character  which  is  not  used  for  editing  the  string.   The 
  229. completion  character  can  be  found  in  the  global   variable 
  230. "TfddChar" which is available after calling Readln. 
  231.  
  232. You  can use the same procedure to data to the screen by doing  a 
  233. "Rewrite"  and using the "Write" procedure to write the  data  to 
  234. the screen. 
  235.  
  236. An  Example  program  using the TFDD  functions  is  provided  as 
  237. TFDDTEST.PAS. You can use this program as an operational  example 
  238. for using the functions.
  239.  
  240. The  "Read"  and "Writeln" functions are not compatible  to  this 
  241. type of TFDD. You should avoid using them with the GwEdit TFDD.
  242.  
  243.  
  244. GwEdit also provides mouse support if you use a Mouse unit (see 
  245. Mouse.Arc in the Borland library). To use the mouse support, just 
  246. enable the mouse functions in GWEDIT, GWCURSE, and AREAWR.
  247.  
  248.  
  249.  
  250. <eof>
  251.